//
// Created by Administrator on 2023/7/29.
//
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

class Solution {
public:
    string firstPalindrome(vector<string> &words) {
        for (string &x: words) {
            if (isPalindrome2(x))return x;
        }
        return "";
    }

    bool isPalindrome(string &str) {
        string tmp = str;
        reverse(tmp.begin(), tmp.end());
        return tmp == str;
    }

    bool isPalindrome2(string &str) {
        int n = str.size();
        int l = 0, r = n - 1;
        while (l < r) {
            if (str[l] != str[r]) return false;
            ++l;
            --r;
        }
        return true;
    }
};

int main() {
    vector<string> words{"abc", "car", "ada", "racecar", "cool"};
    Solution s;
    cout << s.firstPalindrome(words) << endl;

}
